/*
 * Copyright 2020 www.mytijian.com All right reserved. This software is the
 * confidential and proprietary information of www.mytijian.com ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with www.mytijian.com.
 */
package com.mytijian.task.client.orderrevoke;

import com.google.common.collect.Lists;
import com.mytijian.order.base.service.dto.OrderRevokeDTO;
import com.mytijian.task.task.step.DataReader;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

public class OrderRevokeDataReader implements DataReader<List<OrderRevokeDTO>, OrderRevokeDTO> {

    @Override
    public List<OrderRevokeDTO> reader(OrderRevokeDTO input) {
        List<OrderRevokeDTO> list = new ArrayList<>(input.getOrderIds().size());
        for (Integer orderId : input.getOrderIds() ) {
            OrderRevokeDTO orderRevokeDTO = new OrderRevokeDTO();
            BeanUtils.copyProperties(input, orderRevokeDTO,"orderIds");
            orderRevokeDTO.setOrderIds(Lists.newArrayList(orderId));
            list.add(orderRevokeDTO);
        }
        return list;
    }
}
